<template>
  <div v-loading="loading" class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请标题') }}</td>
        <td>{{ form.actTitle }}</td>
        <td class="tit">{{ $t('是否用印') }}</td>
        <td>{{ selectDictLabel(isSealOptions, form.isSeal) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('会议类型') }}</td>
        <td>{{ selectDictLabel(meetingTypeOptions, form.meetingType) }}</td>
        <td class="tit">{{ $t('会议时间') }}</td>
        <td>{{ parseTime(form.meetingTime) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('我方参会人员') }}</td>
        <td>
          <UserSelect
            v-model="form.ourParticipants"
            multiple
            disabled
          />
        </td>
        <td class="tit">{{ $t('其他参会人员') }}</td>
        <td>
          {{ form.otherParticipants }}
        </td>
      </tr>
    </table>
    <div v-if="form.dealMeetingBillList && form.dealMeetingBillList.length > 0">
      <div class="area-header">
        <span class="area-header-title">{{ $t('议案列表') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('议题内容') }}</th>
          <th>{{ $t('我方表决') }}</th>
          <th>{{ $t('说明') }}</th>
          <th>{{ $t('是否为重大事项') }}</th>
          <th v-if="form.actStatus === 'W'">{{ $t('最终结论') }}</th>
          <th>{{ $t('操作') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.dealMeetingBillList" :key="ind">
            <td>{{ $t(v.topicsContent) }}</td>
            <td>
              <dictSelect
                v-model="v.ourVote"
                :is-echo="true"
                dictionary="bill_vote"
              />
            </td>
            <td>{{ $t(v.remark) }}</td>
            <td>{{ selectDictLabel(isSealOptions, v.areMatter) }}</td>
            <td v-if="form.actStatus === 'W'">
              <dictSelect
                v-model="v.finalConclusion"
                :is-echo="true"
                dictionary="final_ourVote"
              />
            </td>
            <td><el-button v-if="v.areMatter === 'Y'" size="mini" type="text" icon="el-icon-view" @click="viewMatterHandle(v)">{{ $t('重大事项信息') }}</el-button></td>
          </tr>
        </tbody>
      </table>
    </div>

    <div v-if="form.isSeal === 'Y' && form.oaSealDetailList && form.oaSealDetailList.length > 0">
      <div class="area-header">
        <span class="area-header-title">{{ $t('用印明细') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('用印主体类型') }}</th>
          <th>{{ $t('用印主体') }}</th>
          <th>{{ $t('用印类型') }}</th>
          <th>{{ $t('备注') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.oaSealDetailList" :key="ind">
            <td>
              <dictSelect
                v-model="v.investMainType"
                :is-echo="true"
                dictionary="main_body_type"
              />
            </td>
            <td>
              <MainBodySelect
                v-model="v.investMain"
                :is-echo="true"
                :parameters="v.investMainType"
              />
            </td>
            <td>{{ selectDictLabels(sealTypeDict, v.sealType) }}</td>
            <td>{{ v.remark }}</td>
          </tr>
        </tbody>
      </table>
    </div>
    <el-dialog :title="$t('重大事项')" :visible.sync="formOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
      <deal-matters-form ref="dealMattersForm" :btn-meeting-hide="btnHide" visible ref-type="meeting" />
    </el-dialog>
    <FileView :list.sync="form.fileList" data-type="deal_meeting" :business-id="autoBusinessId($route.query.id, form)" :btn-show="!otherBtnHide" />

  </div>
</template>

<script>
    import { getDealMeeting } from '@/api/deal/meeting/dealMeeting'
    import dealMattersForm from '@/views/deal/matters/dealMattersForm'
    import MainBodySelect from '@/components/MainBodySelect'
    export default {
      components: {
        dealMattersForm,
        MainBodySelect
      },
        data() {
            return {
                meetingTypeOptions: [],
                sealTypeDict: [],
                isSealOptions: [],
                form: {
                  fileList: []
                },
                // 是否隐藏保存按钮
                btnHide: false,
                // 是否隐藏其它按钮
                otherBtnHide: false,
                formOpen: false,
                // 遮罩层
                loading: false,
                // 操作按钮默认不展示
                buttonShow: false
            }
        },
        created() {
            this.getDicts('meeting_type').then(response => {
                this.meetingTypeOptions = response.data
            })
            this.getDicts('seal_type').then(response => {
              this.sealTypeDict = response.data
            })
            this.getDicts('sys_yes_no').then(response => {
              this.isSealOptions = response.data
            })
            this.$bus.$emit('async_done')
        },
        methods: {
            // 初始化数据
            init(data) {
              this.loading = true
              this.form = {}
              if (data != null && data.id !== undefined) {
                  getDealMeeting(data.id).then(response => {
                      this.form = response.data
                      this.loading = false
                  })
              }
            },
            viewMatterHandle(row) {
              this.formOpen = true
              this.$nextTick(() => {
                if (row.dealMatters) {
                  row.dealMatters['actTitle'] = this.$t('三会管理') + ':' + row.topicsContent
                  row.dealMatters['itemName'] = row.topicsContent
                } else {
                  row.dealMatters = {
                    actTitle: this.$t('三会管理') + ':' + row.topicsContent,
                    itemName: row.topicsContent
                  }
                }
                this.$refs.dealMattersForm.init(row.dealMatters)
              })
          }

        }

    }
</script>
